package org.price.sql.repo.documents.config;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.UUID;

import org.apache.log4j.Logger;

public class InsertThread extends SQLThread {
    private static final Logger LOG = Logger.getLogger(InsertThread.class);

    public InsertThread(Connection connection) {
        super(connection);
    }

    @Override
    protected void executeQuery() throws Exception {

        getConnection().setAutoCommit(false);
        PreparedStatement stm = getConnection().prepareStatement(
                "INSERT INTO  Test (id,title) VALUES (?,?)");
        String id = UUID.randomUUID().toString();
        stm.setString(1, id);
        stm.setString(2, "Test_" + id);

        getConnection().commit();

        LOG.info("Insert into table: " + stm.executeUpdate());
        stm.close();

    }

}
